﻿using System;
using System.Collections.Generic;
using System.Text;
using Lswweb.Model;
using Lswweb.Domain;

namespace Lswweb.Controls
{
    public class ProductStorageList : SkinnedGridView<ProductStorageInfo>
    {
        protected override IList<ProductStorageInfo> GridViewDataSourceHandler(int pageIndex, int pageSize, out int totalRecord)
        {
            string[] searchGroup = SiteUrls.AnalyzeStorageSearchKey(this.SearchKey);

            return ProductStorage.GetProductStorages(
                searchGroup[0],
                searchGroup[1],
                searchGroup[2],
                IsTop,
                IsHot,
                pageIndex, 
                pageSize,
                out totalRecord);
        }

        private string searchKey = SiteContext.Current.SearchKey;
        /// <summary>
        /// 默认值从Url中读取参数SearchKey
        /// </summary>
        public string SearchKey
        {
            get { return searchKey; }
            set { searchKey = value; }
        }

        private bool? iscommend = null;
        public bool? IsHot
        {
            get { return iscommend; }
            set { iscommend = value; }
        }

        private bool? istop = null;
        public bool? IsTop
        {
            get { return istop; }
            set { istop = value; }
        }

        private bool enableDelButton = true;
        public bool EnableDelButton
        {
            get
            {
                if (SiteContext.Current.EnableDelButton != enableDelButton)
                    enableDelButton = SiteContext.Current.EnableDelButton;

                return enableDelButton;
            }
            set { enableDelButton = value; }
        }

        private bool enableTopButton = SiteContext.Current.EnableTopButton;
        public bool EnableTopBtn
        {
            get { return enableTopButton; }
            set { enableTopButton = value; }
        }

        private bool enableHotButton = SiteContext.Current.EnableHotButton;
        public bool EnableHotBtn
        {
            get { return enableHotButton; }
            set { enableHotButton = value; }
        }

        protected override string DefaultSkinFilename
        {
            get { return "ProductStorage/ProductStorageList.ascx"; }
        }
    }
}
